package cn.itbox.example.test.config;

import cn.itbox.uap.util.http.OkHttpExtUtil;
import cn.itbox.uap.util.http.config.ItBoxOkHttpConfig;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @CreateTime: 2024-02-21  10:20
 * @Version: 1.0
 * @Author: huyanbing
 */

@Configuration
public class OkhttpsConfig {


    @Bean
    @Qualifier("itBoxOkHttpConfig")
    @ConfigurationProperties(prefix = "itbox.okhttp")
    public ItBoxOkHttpConfig itBoxOkHttpConfigBean() {
        return new ItBoxOkHttpConfig();
    }

    @Qualifier("okHttpExtUtil")
    @Bean("okHttpExtUtil")
    public OkHttpExtUtil OkHttpExtUtilBean(@Qualifier("itBoxOkHttpConfig") ItBoxOkHttpConfig itBoxOkHttpConfig) {
        OkHttpExtUtil okHttpExtUtil = new OkHttpExtUtil();
        okHttpExtUtil.initClient(itBoxOkHttpConfig);
        return okHttpExtUtil;
    }
}
